/**
 * 产品修改js
 */
var comValidform=null;
var returnStatus=false;
var suggestionUpdate={
	 
	key:null,
		
	startEvent:function(){
		 
		suggestionUpdate.showInfo();
		
		comValidform=$(".com-addForm").Validform({
			datatype:{
				"m0-2" : /^[0-9]+(.[0-9]{1,2})?$/
			},
			tiptype:2,
			tipSweep:true,
			beforeSubmit:function(curform){
				var url = 'mgr/suggestionCtrl/update';
				var params = jsUtils.serializeJson($('.com-addForm'));
				params.responder = userId;
				var cb = function(data){
					alert(data.msg);
					//成功返回
					if(data.resultCode==200){
						localStorage.removeItem(suggestionUpdate.key);
						//关闭窗口并刷新数据
						art.dialog.close();
						returnStatus=true;
					}
				};
				sendApiNoLoadSync(url, params, cb, 'POST');
				return false;
			}
		});
	},
	
	showInfo:function(){
		
		var id = art.dialog.data('updId');
		
		var key = id + "_suggestion_Key";
		var suggestionInfo = eval('(' + localStorage.getItem(key) + ')');
		$("input[name='id']").val(id);
		$("input[name='status']").val(suggestionInfo.status);
		$("input[name='userName']").val(suggestionInfo.userName);
		
		$("textarea[name='suggestion']").val(suggestionInfo.suggestion);
		$("textarea[name='suggestionAnswer']").val(suggestionInfo.suggestionAnswer);
		$("input[name='ctsStr']").val(suggestionInfo.ctsStr);
		$("input[name='updTimeStr']").val(suggestionInfo.updTimeStr);
		
		$("input[name='responderName']").val(suggestionInfo.responderName);
		
		$("input[name='responderDepName']").val(suggestionInfo.responderDepName);
		$("input[name='ctsStr']").val(suggestionInfo.ctsStr);
	},
	
	init:function(){
		suggestionUpdate.startEvent();
	}
}
$(document).ready(function() {
	suggestionUpdate.init();
});
function submitForm(){
	comValidform.submitForm();
	return returnStatus;
}